<?php include $this->getViewFile('/common/Head') ?>
<body class="J_scroll_fixed">
  <style type="text/css">
    .color{
      color:red;
    }
  </style>

  <div class="wrap J_check_wrap">
    <?php include $this->getViewFile('/common/Nav') ?>


     <!-- 搜索 -->
    <div class="h_a">查找</div>
    <?php $objForm = $this->beginWidget( 'CActiveForm', array('id' => 'searchForm','method' => 'get','action' => $this->createUrl('index')) ); ?>
      <div class="search_type cc mb10">
           <div class="mb10">
        统计时间范围：
        <input type="text" name="start_time" class="input length_2 J_date" value="<?php echo $_GET['start_time']?>" placeholder="选择起始时间">
        -
        <input type="text" class="input length_2 J_date" name="end_time" value="<?php echo $_GET['end_time']?>" placeholder="选择结束时间">       

        <input class="search_time btn" type="button" data_id="1" value="今天">
        <input class="search_time btn" type="button" data_id="2" value="昨天">
        <input class="search_time btn" type="button" data_id="3" value="一个星期前">
        <input type="hidden" value="<?php echo $search_time ?>" name="search_time">

        <button class="btn">搜索</button>
          


          </div>
      </div>
    <?php $this->endWidget(); ?>


    <div class="mb10">
      上架商品总数：<?php echo $count['sum_pass'] ?>，上架邮寄商品总数：<?php echo $count['sum_pass_delivery'] ?>
      邮寄样品总数：<?php echo $count['sum_delivery'] ?>，收到样品总数：<?php echo $count['sum_has_delivery'] ?>
    </div>

    <form name="myform" action="" method="post" class="J_ajaxForm">
      <div class="table_list">
        <table width="100%" cellspacing="0">
          <thead>
            <tr>
              <td width="" align="center">审核员</td>
              <td align="center">上架商品个数</td>
              <td align="center">上架邮寄商品个数</td>
              <td align="center">样品占比率</td>
              <td align="center">邮寄样品总数</td>
              <td align="center">收到样品总数</td>
              <td align="center">历史收样未处理数</td>
            </tr>
          </thead>
          <tbody>

             <?php foreach($data as $admin_id => $rs){ ?>
              <tr data-admin_id="<?php echo $admin_id ?>">
                <td  class="username" align="center"><?php echo $rs['username']; ?></td>
                <td  class="sum_pass" align="center"><?php echo GoodsBmModel::getCountForHmtl($rs['sum_pass']) ?></td>
                <td  class="sum_pass_delivery" align="center"><?php echo GoodsBmModel::getCountForHmtl($rs['sum_pass_delivery']) ?></td>
                <td  class="bili" align="center"></td>
                <td  class="sum_delivery" align="center"><?php echo GoodsBmModel::getCountForHmtl($rs['sum_delivery']) ?></td>  
                <td  class="sum_has_delivery" align="center"><?php echo GoodsBmModel::getCountForHmtl($rs['sum_has_delivery']) ?></td>  
                <td  class="sum_not" align="center"><?php echo GoodsBmModel::getCountForHmtl($rs['sum_not']) ?></td>                  
              </tr>
             <?php } ?>

              <tr data-admin_id="<?php echo $admin_id ?>">
                <td  class="username" align="center">总计</td>
                <td  class="sum_pass" align="center"><a href="javascript:void(0)"><?php echo $count['sum_pass'] ?></a></td>
                <td  class="sum_pass_delivery" align="center"><a href="javascript:void(0)"><?php echo $count['sum_pass_delivery'] ?></a></td>
                <td  class="bili" align="center"></td>
                <td  class="sum_delivery" align="center"><?php echo $count['sum_delivery'] ?></td>  
                <td  class="sum_has_delivery" align="center"><?php echo $count['sum_has_delivery'] ?></td>  
                <td  class="sum_not" align="center"><?php echo $count['sum_not'] ?></td>                  
              </tr>

          </tbody>
        </table>

        
      </div>
    </form>


  </div>
  <script src="<?php echo $staticUrl; ?>statics/js/common.js"></script>

  <script type="text/javascript">


  var start_status_savetime = '<?php echo $start_time; ?>';
  var end_status_savetime = '<?php echo $end_time; ?>';
  var history_time = '<?php echo $history_time; ?>';

    $(function(){
      $(".sum_pass,.sum_pass_delivery,.sum_delivery,.sum_has_delivery,.sum_not,.cat").click(function(){
        var obj = $(this);
        var obj_a = obj.find('a').eq(0);
        if(parseInt(obj_a.html()) == 0){
          alert('找不到记录');
          return false;
        }

        var obj_return = {};
        var obj_tr = obj.parents('tr');
        if(obj.hasClass('cat')){
          obj_return.cat_id = obj_a.data('cat_id');
          obj = obj.parents('td').eq(0);
        }

        obj_return.admin_id = obj_tr.data('admin_id');
        //选择了时间范围
        if(parseInt(start_status_savetime)){
          obj_return.start_status_savetime = start_status_savetime;
        }
        if(parseInt(end_status_savetime)){
          obj_return.end_status_savetime = end_status_savetime;
        }        


        if(obj.hasClass('sum_pass')){
          obj_return.status = 1;
        }else if(obj.hasClass('sum_pass_delivery')){
          obj_return.status = 1;
          obj_return.isdelivery = 1;
        }else if(obj.hasClass('sum_delivery')){
          obj_return.isdelivery = 10;
        }else if(obj.hasClass('sum_has_delivery')){
          obj_return.isdelivery = 2;
        }else if(obj.hasClass('sum_not')){
          obj_return.isdelivery = 2;
          obj_return.status = 3;
          obj_return.start_status_savetime = history_time;
          obj_return.end_status_savetime = '';
        }


        var canshu = '?';
        for(var i in obj_return){
          if(obj_return[i] != ''){
            var value = i+"="+obj_return[i]+"&";
            canshu += value;
          }
        }       

        Wind.use('artDialog','iframeTools', function () {
          var dialog = art.dialog.open('<?php echo $this->createUrl("goodslist") ?>'+canshu,{
            title: '信息列表',
            id: 'notice',
            lock: false,
            fixed: true,
            width:700,
            height:500,
            background: "#CCCCCC",
            cancelDisplay: false,          
          });     
        });


      })

      //样品占比率
      var obj_tr = $("tr[data-admin_id]");
      var length = obj_tr.length;
      for(var i=0;i<length;i++){
        var obj_bili = obj_tr.eq(i).find('.bili').eq(0);
        var sum_pass = obj_tr.eq(i).find('.sum_pass a').html();
        var sum_pass_delivery = obj_tr.eq(i).find('.sum_pass_delivery a').html();
        if(parseInt(sum_pass) && parseInt(sum_pass_delivery)){
          var bili = ((sum_pass_delivery/sum_pass)*100).toFixed(2) + "%";
          obj_bili.html(bili);
        }else{
          obj_bili.html('');
        }               
      }
      
    })
  </script>

  <script type="text/javascript">
    $(function(){
      var search_time = $("input[name='search_time']").val();
      if(search_time){
        $(".search_time[data_id='"+search_time+"']").addClass('color');
      }
      
      $(".search_time").click(function(){

        if($(this).hasClass('color')){
          $(".search_time").removeClass('color');
          $("input[name='search_time']").val('');
          return true;
        }
        $(".search_time").removeClass('color');
        $(this).addClass('color');
        $("input[name='search_time']").val($(this).attr('data_id'));
      })
    })
  </script>

</body>
</html>